﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace PPIDesktopClient.General
{
    public class SetupHelper
    {

        public static void CreateSystemFolders()
        {
            try
            {
                DirectoryInfo _repositoryDirectory = new DirectoryInfo(Constants.K_RepositoryFolder);

                if (!_repositoryDirectory.Exists)
                {
                    _repositoryDirectory.Create();
                }
                if (_repositoryDirectory.GetDirectories(Constants.ErrorFolderName + "*").Length == 0)
                    _repositoryDirectory.CreateSubdirectory(Constants.ErrorFolderName);
                if (_repositoryDirectory.GetDirectories(Constants.InboxFolderName + "*").Length == 0)
                    _repositoryDirectory.CreateSubdirectory(Constants.InboxFolderName);
                if (_repositoryDirectory.GetDirectories(Constants.SentFolderName + "*").Length == 0)
                    _repositoryDirectory.CreateSubdirectory(Constants.SentFolderName);
                if (_repositoryDirectory.GetDirectories(Constants.ImageCacheFolderName + "*").Length == 0)
                    _repositoryDirectory.CreateSubdirectory(Constants.ImageCacheFolderName);
                if (_repositoryDirectory.GetDirectories(Constants.OutboxFolderName + "*").Length == 0)
                    _repositoryDirectory.CreateSubdirectory(Constants.OutboxFolderName);

            }
            catch (Exception ex)
            {
                ErrorManager.Log("Exception", ex.Source, ex.Message, ex.StackTrace);
            }
        }

        public static void OpenInWebbrownser(string url)
        {
            System.Diagnostics.Process iexProcess = new System.Diagnostics.Process();
            iexProcess.StartInfo.FileName = "iexplore";
            iexProcess.StartInfo.Arguments = url;
            iexProcess.Start();


        }
    }
}
